package com.itheima.pattern.command;

import java.util.ArrayList;
import java.util.List;

// 调用者角色：服务员类
public class Waitor {

    private List<Command> commands = new ArrayList<>();

    public void setCommand(Command command) {
        commands.add(command);
    }

    // 发起订单功能
    public void orderUp() {
        System.out.println("服务员：新订单来了");
        for (Command command : commands) {
            if (command != null) {
                command.execute();
            }
        }
    }

}
